/*
package com.xm.xmds1705083.service.netty.client;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;

import java.util.concurrent.TimeUnit;

public class ClientStart {

	    private int port;
	    private String host;
	    private SocketChannel socketChannel;
	    private static final EventExecutorGroup group = new DefaultEventExecutorGroup(20);
	    public ClientStart(int port, String host) throws InterruptedException {
	        this.port = port;
	        this.host = host;
	        start();
	    }
	    private void start() throws InterruptedException {
	        EventLoopGroup eventLoopGroup=new NioEventLoopGroup();
	        Bootstrap bootstrap=new Bootstrap();
	        bootstrap.channel(NioSocketChannel.class);
	        bootstrap.option(ChannelOption.SO_KEEPALIVE,true);
	        bootstrap.group(eventLoopGroup);
	        bootstrap.remoteAddress(host,port);
			bootstrap.handler(new ChannelInitializer<SocketChannel>() {
				@Override
				protected void initChannel(SocketChannel socketChannel) throws Exception {
					socketChannel.pipeline().addLast(new IdleStateHandler(30,25,0));
					socketChannel.pipeline().addLast(new ObjectEncoder());
					//socketChannel.pipeline().addLast( new ClientSocketEntityDecoder());
					socketChannel.pipeline().addLast(new ObjectDecoder(ClassResolvers.cacheDisabled(null)));
					//new ObjectDecoder(ClassResolvers.cacheDisabled(ClientSocketEntityDecoder.class.getClassLoader()))
					*/
/**
					 * 	socketChannel.pipeline().addLast(new ObjectEncoder());
					 socketChannel.pipeline().addLast(new ObjectDecoder(ClassResolvers.cacheDisabled(null)));
					 * *//*

					socketChannel.pipeline().addLast(new NettyClientHandler());
				}
			});
			ChannelFuture future =bootstrap.connect(host,port).sync();
	        if (future.isSuccess()) {
	            socketChannel = (SocketChannel)future.channel();
	            System.out.println("$$$$$$ netty客户端连接上服务器 $$$$$$");
	        }
	    }


	    public static void main(String[]args) throws InterruptedException {

			ClientStart bootstrap = new ClientStart(8833,"localhost");//116.62.19.114
			bootstrap.start();
	        while (true){
	            TimeUnit.SECONDS.sleep(10);
	        }
	    }
}
*/
